<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\Picture;

class Activity extends Model
{
    protected $table = 'activity';

    protected $primarykey = 'id';

    public $timestamps = false;

    protected $appends = array('mobile_activity_thumb','mobile_bg_img','mobile_tit_img');


    protected $fillable = [
        'name','is_recommend','description','template','add_time','sort_order','activity_thumb','m_activity_thumb','identification',
        'bg_img','m_bg_img','bg_color','bg_margin_top',
        'tit_img','m_tit_img','tit_width','tit_height','tit_line_height','tit_position','tit_font_color','tit_font_size',
        'sidebar_bg_color','sidebar_hover_color','sidebar_top','sidebar_left','sidebar_line_height','sidebar_font_size','sidebar_font_color'
    ];

    function getMobileActivityThumbAttribute(){

        $activity_thumb = $this->getAttribute('m_activity_thumb');
        if(!$activity_thumb){
            return null;
        }

        return Picture::find($activity_thumb)->url;


    }
    function getMobileBgImgAttribute(){

        $bg_img = $this->getAttribute('m_bg_img');

        if(!$bg_img){
            return null;
        }
        return Picture::find($bg_img)->url;


    }
    function getMobileTitImgAttribute(){

        $tit_img = $this->getAttribute('m_tit_img');

        if(!$tit_img){
            return null;
        }
        return Picture::find($tit_img)->url;


    }






}
